﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WCFMINERP.Order.Forms
{
    public partial class UCOrderInfo : UserControl
    {
        private int _orderInfoId;

        public int OrderInfoId { get { return _orderInfoId; } }
        public string PhotoNum
        {
            set 
            {
                lbPhotoNum.Text = value;
            }
        }
        public UCOrderInfo(string productName,string ctmName,string photoNum,int orderInfoId)
        {
            InitializeComponent();
            lbProductName.Text = productName;
            lbCtm.Text = ctmName;
            lbPhotoNum.Text = photoNum;
            _orderInfoId = orderInfoId;
        }

        private void Fire()
        {
            FrmOrder frm = (FrmOrder)this.FindForm();
            frm.showOrderInfoHander.Invoke(_orderInfoId);
        }

        private void txtProductName_DoubleClick(object sender, EventArgs e)
        {
            Fire();
        }

        private void lbCtm_DoubleClick(object sender, EventArgs e)
        {
            Fire();
        }

        private void lb66_DoubleClick(object sender, EventArgs e)
        {
            Fire();
        }

        private void lbPhotoNum_DoubleClick(object sender, EventArgs e)
        {
            Fire();
        }

        private void UCOrderInfo_DoubleClick(object sender, EventArgs e)
        {
            Fire();
        }

        private void UCOrderInfo_MouseEnter(object sender, EventArgs e)
        {
            this.BorderStyle = BorderStyle.FixedSingle;
        }

        private void UCOrderInfo_MouseLeave(object sender, EventArgs e)
        {
            this.BorderStyle = BorderStyle.None;
        }

        private void UCOrderInfo_MouseClick(object sender, MouseEventArgs e)
        {
            MouseRightClick(sender, e);
        }

        private void MouseRightClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                contextMenuStrip1.Show(Cursor.Position);
            }
        }

        private void lbPhotoNum_MouseClick(object sender, MouseEventArgs e)
        {
            MouseRightClick(sender, e);
        }

        private void lb66_MouseClick(object sender, MouseEventArgs e)
        {
            MouseRightClick(sender, e);
        }

        private void lbCtm_MouseClick(object sender, MouseEventArgs e)
        {
            MouseRightClick(sender, e);
        }

        private void lbProductName_MouseClick(object sender, MouseEventArgs e)
        {
            MouseRightClick(sender, e);
        }

        private void 删除产品ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DeleteOrderInfo();
        }
        /// <summary>
        /// 删除产品
        /// </summary>
        private void DeleteOrderInfo()
        {
            FrmOrder frm = (FrmOrder)this.FindForm();
            frm.deleteOrderInfoHander.Invoke(OrderInfoId);

        }

    }
}
